#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>


int main(int argc,const char*argv[])
{
	if(argc!=3){printf("文件源缺失\n");return -1;}
	int p1=-1,p2=-1;
	if((p1=open(argv[1],O_RDONLY))==-1||(p2=open(argv[2],O_WRONLY|O_CREAT|O_TRUNC,0664))==-1){perror("打开失败：");return -1;}
	int n=-1;
	char x;
	while((n=read(p1,&x,1))!=0)
	{
		write(p2,&x,n);
		write(1,&x,n);
	}
	close(p1);
	close(p2);
	printf("拷贝完成\n");

	return 0;
}
